package com.ktwlsoft.fundmanage.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.context.annotation.Configuration;

/** 设置对象映射，解决Long类型转json精度丢失问题*/
@Configuration
public class CustomObjectMapper extends ObjectMapper {

    private static final long serialVersionUID = -2916716415368585309L;

    /**
     * 解决Long类型转json精度丢失问题 on 2019/3/27 0027 12:03
     */
    public CustomObjectMapper() {
        super();
        SimpleModule simpleModule = new SimpleModule();
        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
        simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
        registerModule(simpleModule);
    }
}
